package com.tony.business.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringApplicationRunListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

import java.util.Arrays;

/**
 * @author x
 */
@Slf4j
public class CustomApplicationContextListener implements SpringApplicationRunListener {
    private SpringApplication application;
    private String[] args;
    public CustomApplicationContextListener(SpringApplication springApplication, String[] args){
        this.application = springApplication;
        this.args = Arrays.copyOf(args, 0);
    }

    @Override
    public void starting() {
        log.info(application.getMainApplicationClass().toString());
        log.info(Arrays.toString(args));
    }

    @Override
    public void environmentPrepared(ConfigurableEnvironment environment) {

    }

    @Override
    public void contextPrepared(ConfigurableApplicationContext context) {

    }

    @Override
    public void contextLoaded(ConfigurableApplicationContext context) {

    }

    @Override
    public void started(ConfigurableApplicationContext context) {

    }

    @Override
    public void running(ConfigurableApplicationContext context) {

    }

    @Override
    public void failed(ConfigurableApplicationContext context, Throwable exception) {

    }
}
